package main

import (
	_ "gopkg.in/go-playground/validator.v9"
)

//type RegisterReq struct {
//	Username 	string	`json:"username" validate:"gt=0"`
//	PasswordNew	string	`json:"password_new" validate:"gt=0"`
//	PasswordRepeat string `json:"password_repeat" validate:"eqfield=PasswordNew"`
//	Email string 	`json:"email" validate:"email"`
//}

//func register(req RegisterReq) error {
//	if len(req.Username) > 0 {
//		if len(req.PasswordNew) > 0 && len(req.PasswordRepeat) > 0 {
//			if req.PasswordNew == req.PasswordRepeat {
//				if emailFormatValid(req.Email) {
//					createUser()
//					return nil
//				} else {
//					return errors.New("invalid email")
//				}
//			} else {
//				return errors.New("password and password reinput must be longer than 0")
//			}
//		}
//	} else {
//		return errors.New("length of username cannot be 0")
//	}
//}

//func register(req RegisterReq) error {
//	if len(req.Username) == 0 {
//		return errors.New("length of username cannot be 0")
//	}
//
//	if len(req.PasswordNew) == 0 || len(req.PasswordRepeat) == 0 {
//		return errors.New("password and password reinput must be longer than 0")
//	}
//
//	if req.PasswordNew != req.PasswordRepeat {
//		return errors.New("password and password reinput must be the same")
//	}
//
//	if emailFormatValid(req.Email) {
//		return errors.New("invalid email")
//	}
//
//	createUser()
//	return nil
//}
//
//validate := validator.New()
//
//func validate(req RegisterReq) error {
//	err := validate.Struct(req)
//	if err != nil {
//		//doSomething()
//		return err
//	}
//}
